package com.lc.java.ai.langchain4j.config;

import com.lc.java.ai.langchain4j.store.MongoDbChatMemoryStore;
import dev.langchain4j.memory.chat.ChatMemoryProvider;
import dev.langchain4j.memory.chat.MessageWindowChatMemory;
import dev.langchain4j.store.memory.chat.InMemoryChatMemoryStore;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author liuchun
 * @version 1.0
 * @date 2025/6/3 21:36
 */
@Configuration
public class SeparateChatAssistantConfig {

    @Autowired
    private MongoDbChatMemoryStore mongoDbChatMemoryStore;

    @Bean
    public ChatMemoryProvider chatMemoryProvider(){
        return memoryId -> MessageWindowChatMemory.builder()
                .maxMessages(10)
                .id(memoryId)
                .chatMemoryStore(mongoDbChatMemoryStore)
                .build();
    }
}
